from django.db import models
from django.contrib.auth import get_user_model
User = get_user_model()
from music import *
from music.models import *
from ckeditor.fields import RichTextField
class Song(models.Model):
    pass

class Playlist(models.Model):

    LANGUAGE = (
        ('1', '欧美'),
        ('2', '华语'),
        ('3', '日韩'),
        ('4', '粤语'),
        ('5', '小语种'),
    )

    playlist_name = models.CharField(max_length=80, verbose_name='歌单名称', help_text='歌单名称')
    time = models.DateTimeField(auto_now=True, verbose_name='歌单创建时间', help_text='歌单创建时间')
    is_hot = models.BooleanField(default=False, verbose_name='是否是热门', help_text='是否是热门歌单')
    hot_index = models.CharField(max_length=5, default='0', verbose_name='热门中的排序', help_text='热门中的排序')
    is_self = models.BooleanField(default=False, verbose_name='是否是个性', help_text='是否是个性歌单')

    languages = models.CharField(max_length=10, verbose_name='语种', help_text='选择语种', choices=LANGUAGE)
    style = models.ForeignKey(MusicStyle, verbose_name='歌曲风格', help_text='歌曲风格', blank=True)
    scene = models.ForeignKey(MusicScene, verbose_name='歌曲场景', help_text='歌曲场景', blank=True)
    emotion = models.ForeignKey(MusicEmotion, max_length=10, verbose_name='歌曲情感', help_text='歌曲情感', blank=True)
    theme = models.ForeignKey(MusicTheme, max_length=10, verbose_name='歌曲主题', help_text='歌曲主题', blank=True)
    self_index = models.CharField(max_length=5, default='0', verbose_name='个性中的排序', help_text='个性中的排序')
    # language = models.IntegerField(default=2, verbose_name='语言', choices=LANGUAGE, help_text='语言')
    # style = models.IntegerField(default=2, verbose_name='风格', choices=STYLE, help_text='风格')
    # scene = models.IntegerField(default=2, verbose_name='场景', choices=SCENE, help_text='场景')
    # emotion = models.IntegerField(default=2, verbose_name='情感', choices=EMOTION, help_text='情感')
    # theme = models.IntegerField(default=2, verbose_name='主题', choices=THEME, help_text='主题')
    desc = RichTextField(default='青春python', max_length=500, verbose_name='歌单简介', help_text='歌单简介')
    song = models.ManyToManyField(OneMusicCreate, verbose_name='包含歌曲', help_text='包含歌曲')
    play_num = models.IntegerField(default=0, verbose_name='用户播放次数', help_text='用户播放次数')

    class Meta:
        verbose_name_plural = verbose_name = '歌单信息'

    def __str__(self):
        return self.playlist_name
